﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using BestLifePOS_Core.Exceptions.DataBase;
using BestLifePOS_Core.Data.Core;

namespace BestLifePOS_Core.Data.Commands
{
    class BestlifeShiftMDataAction : BestLifeDataAction<string>
    {
        private string Gvterm;
        private DateTime GvdateC;
        private string Gvuse;
        


        public BestlifeShiftMDataAction(string Pterm)
       {
          //  this.PPterm = Pterm;
            Gvterm = "1.000";
          //  GvdateC = System.DateTime.Now;
           // GvdateC = Convert.ToDateTime("2013-02-11 12:18:09.550");
            Gvuse = "Admin";
        }


        public override string Body(SqlConnection PConn)
        {

            string totSM="";
            try
            {
         //       ProTable.Columns.Add("Stock_Id");
              

                List<string> LvList = new List<string>();


                SqlCommand LvCommand = new SqlCommand();
                LvCommand.Connection = PConn;
                LvCommand.CommandType = CommandType.StoredProcedure;
                LvCommand.CommandText = "dbo.GetTotalByTermO";
                LvCommand.Parameters.Add(new SqlParameter("@Term_Id", Gvterm));//when passing parameters to the SP
               // LvCommand.Parameters.Add(new SqlParameter("@Date_Create", GvdateC));
                LvCommand.Parameters.Add(new SqlParameter("@User_Id", Gvuse));
                SqlDataReader LvReader = LvCommand.ExecuteReader();
                while (LvReader.Read())
                {
                totSM = LvReader[0].ToString();
                }
                
            }
            catch (BestlifeDatabaseException e)
            {
                throw new BestlifeDatabaseException(e);
            }
            return totSM;
        }
    }
}